package com.coding.service.impl;

import com.coding.mapper.VideoMessageMapper;
import com.coding.pojo.VideoCommentReply;
import com.coding.pojo.VideoCommentReplyRelate;
import com.coding.pojo.VideoComments;
import com.coding.service.VideoMessageService;
import com.coding.vo.UserCommentData;
import com.coding.vo.UserCommentVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class VideoMessageServiceImpl implements VideoMessageService {
    @Autowired
    VideoMessageMapper mapper;

    @Override
    public String test() {
        return "消息测试";
    }

    @Override
    public List<VideoComments> initComments() {
        List<VideoComments> userComments = mapper.init();

//        System.out.println(userComments);
//
//        List<UserCommentVo> commentLists = new ArrayList<>();
//
//        for (VideoComments i : userComments){
//            UserCommentData data = mapper.getUserInfo(i.getUserId());
//            System.out.println("**********************");
//            System.out.println(i.getUserId());
//            System.out.println(data);
//            System.out.println("**********************");
//            UserCommentVo vo = new UserCommentVo();
//            vo.setAvatar(data.getAvatar());
//            vo.setUserName(data.getUserName());
//            vo.setContent(i.getContents());
//            commentLists.add(vo);
//
//        }

        return userComments;
    }

    @Override
    public List<VideoCommentReply> initReplies() {
        return mapper.initReply();
    }

    @Override
    public List<VideoCommentReplyRelate> initRelates() {
        return mapper.initRelates();
    }

    @Override
    public Boolean sendCommnet(Long videoId, Long userId, String content) {

        return mapper.sendComment(videoId, userId, content) > 0;
    }


}
